import { http } from '@/utils/http'

// 新增
export const appAdd = (data?: object) => {
  return http.request('post', '/manage/app/app', { data })
}
// 编辑
export const editAdd = (data?: object) => {
  return http.request('put', '/manage/app/app', { data })
}
// 列表
export const getAppList = (params?: object) => {
  return http.get<{}, HttpPaginationResponse>('/manage/app/apps', { params })
}
// 详情信息
export const getAppDetail = (id: string) => {
  return http.get<{}, HttpResponse>(`/manage/app/${id}`)
  // return http.request<ApifoxModel>("delete", `/pm/report/${params}`);
}
// 删除
export const deleteApi = (ids: string) => {
  return http.request('delete', `/manage/appApi/${ids}`)
}
// 部门列表
export const getDeptList = (params?: object) => {
  return http.get<{}, HttpResponse>('/system/dept/list', { params })
}
// 查询应用接口信息列表
export const getAppApiList = (params?: object) => {
  return http.get<{}, HttpPaginationResponse>('/manage/appApi/addedAppApis', { params })
}
// 查询接口基本信息列表
export const getApiInfoList = (params?: object) => {
  return http.request<HttpPaginationResponse<Array<ApiInfo>>>('get', '/manage/apiInfo/apis', {
    params,
  })
}
// 应用添加公共接口
export const addPublicApi = (data?: object) => {
  return http.request('post', '/manage/appApi/appApiPublic', { data })
}
// 应用添加私有接口
export const addPrivateApi = (data?: object) => {
  return http.request('post', '/manage/appApi/appApiPrivate', { data })
}

/**
 * 改变接口状态
 * @param payload
 * @returns
 */
export const changeStatus = (payload?: ChangeStatusData) => {
  return http.request('put', '/manage/appApi/changeStatus', { data: payload })
}

type ChangeStatusData = {
  gxId: string
  gxIsEnabled: string
}

export interface ApiInfo {
  id: string
  apiName: string
  apiType: string
  apiDesc: string
}
